package aRole

import (
	"context"
	"t-go-zero/service/user/rpc/userclient"

	"t-go-zero/service/user/api/internal/svc"
	"t-go-zero/service/user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ARoleUpLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewARoleUpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ARoleUpLogic {
	return &ARoleUpLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ARoleUpLogic) ARoleUp(req *types.ARoleUpRequest) (resp *types.Response, err error) {

	_, err = l.svcCtx.UserRpc.ARoleUpdate(l.ctx, &userclient.ARoleUpdateReq{
		Id:     req.Id,     // 角色ID
		Name:   req.Name,   // 角色名称
		Remark: req.Remark, // 备注
	})
	if err != nil {
		return nil, err
	}
	return &types.Response{
		Code: 0,
		Msg:  "成功",
		Data: nil,
	}, nil
}
